<script type="">

    $(document).ready(function(){                    
        $("#open_pop,#open_pop_2").colorbox({inline:true,width:"450px", height:"255px",opacity:0.1,onLoad: function(){  
                $('#cboxClose').remove();              
            }        
        });        

        $('#create_date,#create_date_edit').datepicker({
            changeYear: true,
            dateFormat:'dd/mm/yy',                                    
            showOn:'both',           
            buttonImage: '<?=Yii::app()->params["urlRs"]."/images/calendar.png"?>',
            buttonImageOnly: 'true'
        });   

        $(".ui-datepicker-trigger").css("margin-bottom","-5px");
        $(".ui-datepicker-trigger").css("margin-left","5px"); 

    });

    function edit_mode(id){
        $('#edit_id').val(id);            
        $('#version_name_edit').val($('#version_name_'+id).html());
        $('#create_date_edit').val($('#version_date_'+id).html());
        $('#version_description_edit').val($('#version_des_'+id).html());    
    }    

    function update_version(){
        var id = $('#edit_id').val();
        if(id == 0){
            var version_name = $('#version_name').val();       
            var version_description = $('#version_description').val();               
            //var version_status = $('#version_status').val();       
            var version_status = 1;       
            var create_date = $('#create_date').val();                          
        }else{
            var version_name = $('#version_name_edit').val();       
            var version_description = $('#version_description_edit').val();               
            //var version_status = $('#version_status').val();       
            var version_status = 1;       
            var create_date = $('#create_date_edit').val();                       
        }        

        if(version_name == ''){
            alert('Bạn chưa nhập tên cho phiên bản!');return false;
        }

        var strUrl = '<?=$url->createUrl("project/ajaxUpdateVersion") ?>';            
        loadingAjax();
        $.ajax({
            type: "GET",
            url: strUrl,
            data: {id:id,version_name:version_name,version_description:version_description,version_status:version_status,create_date:create_date},            
            success: function(msg){                            
                if(msg==1){                       
                    location.reload();   
                }
            }
        });

        closeLoadingAjax();
    }

    function delete_version(version_id){
        if(confirm('Bạn có chắc chắn muốn xóa?')){
            var strUrl = '<?=$url->createUrl("project/ajaxDeleteVersion") ?>';            
            loadingAjax();
            $.ajax({
                type: "GET",
                url: strUrl,
                data: {version_id:version_id},
                success: function(msg){                            
                    if(msg==1){                       
                        $('#version_row_'+version_id).hide('slow');
                    }
                }
            });

            closeLoadingAjax();            
        }
    }

</script>